<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/ui.xhtml">

<ui:define name="head">
    <script type="text/javascript" src="#{request.contextPath}/UI/support/pub.js"/>
    <script type="text/javascript" language="javascript">
        document.onkeydown = function TabReplace() {
            if (event.keyCode == 13) {
                if (event.srcElement.tagName != 'BUTTON')
                    event.keyCode = 9;
                else
                    event.srcElement.click();
            }
        }
        function actSelect(obj, pageName) {
            var pkid = obj;
            var sfeature = "dialogwidth:1300px;dialogheight:700px;center:yes;location:no;help:no;resizable:no;scroll:yes;status:no";
            var arg = new Object();
            arg.doType = "select";
            if (pageName == "Tk_Detail") {
                var rtn = dialog("../item/itemHieRelapMng_Tkctt.xhtml?strType=0&amp;strTkCttPkid=" + pkid + "", arg, sfeature);
            } else if (pageName == "Attachment") {
                //var sfeature = "dialogwidth:400px;dialogheight:300px;center:yes;location:no;help:no;resizable:no;scroll:yes;status:no;toolbar:no";
                var rtn = window.open("/epss/servlet/ShowServlet?operType=Mng&amp;strType=0&amp;strPkid=" + pkid + "",
                        'popupwindow',
                        'height = 300,width = 450,location = no,resizable = no,scrollbars = yes,status = no,toolbar = no,top = 100');
                //var rtn =dialog("../attachment/attachment_Mng.jsp?strType=0&amp;strPkid="+pkid+"",arg,sfeature);
                //var rtn =window.showModalDialog("../attachment/attachment_Mng.jsp?strType=0&amp;strPkid="+pkid+"",arg,sfeature);
            }
        }
    </script>
    <style type="text/css">
        .img {
            width: 20px;
            height: 30px;
        }

        .c_c {
            background: gray;
        }
    </style>

</ui:define>
<ui:define name="content">
    <div style="margin:5px;">
        <h:form id="form">
            <p:growl id="msgs" showDetail="true"/>
            <p:focus for="id"/>
            <p:panel id="ppCondition" header="总包合同登记信息录入" style="width: 100%">
                <h:panelGrid>
                    <h:selectOneRadio id="radio" value="#{esPowerAction.strOperType}">
                        <f:selectItem itemLabel="查询" itemValue="strRadioQry"/>
                        <f:selectItem itemLabel="编辑" itemValue="strRadioEdit"/>
                        <p:ajax update="pgCondition,pdt"
                                listener="#{esInitCttAction.radioOnClickForPowerAction('Mng','0')}"/>
                    </h:selectOneRadio>
                </h:panelGrid>
                <h:panelGrid id="pgCondition" columns="2" style="width: 100%">
                    <h:panelGrid id="pgTkctt">
                        <h:panelGrid columns="4">
                            <h:outputLabel value="合同编号：" for="id" style="font-weight: bold"/>
                            <p:inputText id="id" value="#{esInitCttAction.itemEsInitCtt.id}"
                                         style="width:127px"/>

                            <h:outputLabel value="合同名称：" for="cttName" style="font-weight: bold"/>
                            <p:inputText id="cttName" value="#{esInitCttAction.itemEsInitCtt.name}"
                                         style="width:127px"/>
                        </h:panelGrid>

                        <h:panelGrid columns="4">
                            <h:outputLabel value="签订甲方：" for="signPartA" style="font-weight: bold"/>
                            <p:selectOneMenu id="signPartA" value="#{esInitCttAction.itemEsInitCtt.signPartA}"
                                             style="width:131px">
                                <f:selectItems value="#{esCommonAction.customerlist}"/>
                            </p:selectOneMenu>

                            <h:outputLabel value="签订乙方：" for="signPartB" style="font-weight: bold"/>
                            <p:selectOneMenu id="signPartB" value="#{esInitCttAction.itemEsInitCtt.signPartB}"
                                             style="width:131px">
                                <f:selectItems value="#{esCommonAction.customerlist}"/>
                            </p:selectOneMenu>
                        </h:panelGrid>
                        <h:panelGrid columns="6">
                            <h:outputLabel value="开始时间：" for="cttStartDate" style="font-weight: bold"/>
                            <p:inputText id="cttStartDate" value="#{esInitCttAction.itemEsInitCtt.cttStartDate}"
                                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                         style="width:127px"/>

                            <h:outputLabel value="截止时间：" for="cttEndDate" style="font-weight: bold"/>
                            <p:inputText id="cttEndDate" value="#{esInitCttAction.itemEsInitCtt.cttEndDate}"
                                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                         style="width:127px"/>

                            <h:outputLabel value="签订日期：" for="signDate" style="font-weight: bold"/>
                            <p:inputText id="signDate" value="#{esInitCttAction.itemEsInitCtt.signDate}"
                                         onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                         style="width:127px"/>
                        </h:panelGrid>

                        <h:panelGrid columns="6">
                            <h:outputLabel value="状态标志：" for="statusFlag" style="font-weight: bold"/>
                            <p:selectOneMenu id="statusFlag" value="#{esInitCttAction.itemEsInitCtt.statusFlag}"
                                             style="width:131px">
                                <f:selectItems value="#{esPowerAction.statusFlagList}"/>
                            </p:selectOneMenu>

                            <h:outputLabel value="结束标志：" for="endFlag" style="font-weight: bold"/>
                            <p:selectOneMenu id="endFlag" value="#{esInitCttAction.itemEsInitCtt.endFlag}"
                                             style="width:131px">
                                <f:selectItems value="#{esPowerAction.endFlagList}"/>
                            </p:selectOneMenu>

                            <h:outputLabel value="删除标志：" for="deletedFlag" style="font-weight: bold"/>
                            <p:selectOneMenu id="deletedFlag" value="#{esInitCttAction.itemEsInitCtt.deletedFlag}"
                                             style="width:131px">
                                <f:selectItems value="#{esPowerAction.deleteFlagList}"/>
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="2">
                            <h:outputLabel value="备注内容：" for="note" style="font-weight: bold"/>
                            <p:inputTextarea id="note" value="#{esInitCttAction.itemEsInitCtt.note}"
                                             rows="1" autoResize="false" style="width:127px"/>
                        </h:panelGrid>
                    </h:panelGrid>
                    <h:panelGrid style="width:10%">
                        <p:commandButton id="qryBtn" value="查询"
                                         action="#{esInitCttAction.onQueryAction('0','False')}"
                                         style="width:90px"
                                         update="pdt,msgs"
                                         rendered="#{esPowerAction.strBtnQryRendered}">
                        </p:commandButton>
                        <p:commandButton id="submitBtn" value="#{esInitCttAction.strSubmitBtnName}"
                                         action="#{esInitCttAction.onClickForMngAction('0')}"
                                         style="width:90px;"
                                         update="pdt,msgs,ppCondition"
                                         rendered="#{esPowerAction.strBtnEditRendered}">
                        </p:commandButton>
                        <p:commandButton id="resetBtn" value="重置"
                                         action="#{esInitCttAction.resetAction}"
                                         style="width:90px"
                                         update="pgCondition,msgs">
                        </p:commandButton>
                    </h:panelGrid>
                </h:panelGrid>
            </p:panel>

            <p:ajaxStatus style="width:16px;height:16px;">
                <f:facet name="start">
                    <h:graphicImage value="/images/ajaxloading.gif"/>
                </f:facet>
                <f:facet name="complete">
                    <h:outputText value=""/>
                </f:facet>
            </p:ajaxStatus>

            <!--列表维护-->
            <p:contextMenu for="pdt">
                <p:menuitem value="增加" icon="ui-icon-plus"
                            actionListener="#{esInitCttAction.selectRecordAction('Mng','Add','0')}"
                            update="pdt,msgs,ppCondition">
                </p:menuitem>
                <p:menuitem value="更新" icon="ui-icon-arrowrefresh-1-w"
                            actionListener="#{esInitCttAction.selectRecordAction('Mng','Upd','0')}"
                            update="pdt,msgs,ppCondition">
                </p:menuitem>
                <p:menuitem value="删除" icon="ui-icon-close"
                            actionListener="#{esInitCttAction.selectRecordAction('Mng','Del','0')}"
                            update="pdt,msgs,ppCondition">
                </p:menuitem>
                <p:menuitem value="详细内容" icon="ui-icon-search"
                            oncomplete="actSelect(DtInitTkcttList.selection,'Tk_Detail')">
                </p:menuitem>
                <p:menuitem value="附件" icon="ui-icon-search"
                            oncomplete="actSelect(DtInitTkcttList.selection,'Attachment')">
                </p:menuitem>
            </p:contextMenu>
            <p:dataTable id="pdt" style="width:100%;"
                         value="#{esInitCttAction.itemEsInitCttList}"
                         var="record"
                         rowKey="#{record.pkid}"
                         selection="#{esInitCttAction.itemEsInitCttSelected}"
                         selectionMode="single"
                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                         paginator="true"
                         paginatorPosition="bottom"
                         rows="15"
                         rowsPerPageTemplate="100,50,30,15,5"
                         emptyMessage="数据记录为空..."
                         widgetVar="DtInitTkcttList"
                         rowStyleClass="#{record.statusFlag eq '0'? null:record.statusFlag eq null? null:'c_c'}"
                    >

                <!--<p:ajax event="rowSelect" listener="#{esInitCttAction.onRowSelect}" update=":form"/>-->

                <p:column headerText="pkid" style="display:none;" rendered="false">
                    <h:outputText id="tetid" style="display:none;" rendered="false" value="#{record.pkid}"/>
                </p:column>

                <p:column headerText="总包合同号" style="text-align:center">
                    <h:outputText value="#{record.id}"/>
                </p:column>

                <p:column headerText="总包合同名" style="text-align:left">
                    <h:outputText value="#{record.name}"/>
                </p:column>

                <p:column headerText="签订甲方" style="text-align:left">
                    <h:outputText value="#{esCommonAction.getCustNameByCustIdFromList(record.signPartA)}"/>
                </p:column>

                <p:column headerText="签订乙方" style="text-align:left">
                    <h:outputText value="#{esCommonAction.getCustNameByCustIdFromList(record.signPartB)}"/>
                </p:column>

                <p:column headerText="开始时间" style="width:66px;text-align:center">
                    <h:outputText value="#{record.cttStartDate}"/>
                </p:column>

                <p:column headerText="截止时间" style="width:66px;text-align:center">
                    <h:outputText value="#{record.cttEndDate}"/>
                </p:column>

                <p:column headerText="状态标志" style="width:66px;text-align:center">
                    <h:outputText value="#{esPowerAction.getLabelByValueInStatusFlaglist(record.statusFlag)}"/>
                </p:column>

                <p:column headerText="原因" style="width:66px;text-align:center">
                    <h:outputText value="#{esPowerAction.getLabelByValueInPreStatusFlaglist(record.preStatusFlag)}"/>
                </p:column>

                <p:column headerText="结束标志" style="width:66px;text-align:center">
                    <h:outputText value="#{esPowerAction.getLabelByValueInEndFlagList(record.endFlag)}"/>
                </p:column>

                <p:column headerText="签订日期" style="width:66px;text-align:center">
                    <h:outputText value="#{record.signDate}"/>
                </p:column>

            </p:dataTable>
        </h:form>
    </div>
</ui:define>

</ui:composition>